<!--
 * @Autor: 黄旗
 * @Date: 2020-07-17 09:00:14
-->
<template>
    <Cascader
        v-show="params.show ? params.show.show : true"
        :style="params.style"
        :data="params.childList"
        v-model="params.value"
        :render-format="params.format || format"
        :disabled="params.disabled"
        :clearable="params.clearable"
        :placeholder="params.placeholder"
        :trigger="params.trigger || 'hover'"
        :change-on-selec="params.changeOnSelec"
        :size="params.size"
        :load-data="params.loadData"
        :filterable="params.filterable"
        :not-found-text="params.notFoundText"
        :transfer="params.transfer"
        :change-on-select="params.changeonSelect"
        :element-id="params.elementId"
        @on-change="$emit('on-change', $event)"
    ></Cascader>
</template>

<script>
    export default {
        props: ['params'],
        methods: {
            format (labels, selectedData) {
                const index = labels.length - 1;
                const data = selectedData[index] || false;
                if (data && data.code) {
                    return labels[index] + ' - ' + data.code;
                }
                return labels.join('/');
            }
        }
    };
</script>
